<?php


namespace app\home\controller;


use app\base\BaseController;
use app\home\model\TransferOrderDetail;
use app\home\severs\InventoryOrderSever;
use PhpOffice\PhpSpreadsheet\IOFactory;
use think\Exception;
use think\facade\Db;
use think\facade\View;

/**
 * Class InventoryOrder
 * @package app\home\controller
 * 盘点单
 */
class InventoryOrder extends BaseController
{
    protected $table='inventory_order';
    protected $title='盘点单';
    private $sessionKey='pageInventoryOrder';

    /**
     * date:2024/3/21
     * 列表
     */
    public function index()
    {
        $param=$this->param;
        if (request()->isAjax()) {

            $where[]=['io.status','>',-1];
            foreach (['w_name','u_name'] as $i){
                if (isset($param[$i])&&$param[$i]){
                    $k=str_replace('_','.',$i);
                    $where[]=[$k,'like','%'.$param[$i].'%'];
                }
            }
            foreach (['io_id','io_status'] as $i){
                if (isset($param[$i])&&$param[$i]){
                    $k=str_replace('_','.',$i);
                    $where[]=[$k,'=',$param[$i]];
                }
            }
            if (isset($param['i_incomTime'])&&$param['i_incomTime']){
                $times=explode('~',$param['i_incomTime']);
                $where[]=['io.inventoryTime','between',$times];
            }
            session($this->sessionKey,$where);
            $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
            $list = Db::name($this->table)->alias('io')
                ->join('admin u','u.id=io.inventory_user','left')
                ->join('warehouse w','w.id = io.warehouse_id')
                ->where($where)
                ->order('io.id desc')
                ->field("io.*,w.name as wName,u.name as username,
                (select sum(pdNum) from fy_inventory_order_detail iod where iod.status=2 and iod.inventory_id=io.id and iod.type=1)profitNum,
                (select sum(pdNum) from fy_inventory_order_detail iod where iod.status=2 and iod.inventory_id=io.id and iod.type=2)lossNum")
                ->paginate($rows);
            return table_assign(0, '', $list);
        } else {
            $warehouseList=Db::name('warehouse')->where('status',1)->field('id,name')->select();
            View::assign('warehouseList',$warehouseList);
            return view();
        }

    }

    /**
     * @return \json|\think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * date:2024/3/21
     * 添加
     */
    public function add()
    {
        $param = get_params();
        if (request()->isAjax()) {
            $postData=$this->param;
            $mxid=$postData['mxid']??[];
            $material_id=$postData['material_id']??[];
//            $incom_receipt_detail_id=$postData['incom_receipt_detail_id']??[];
            $warehouse_id=$postData['warehouse_id']??'';
            $num=$postData['num']??[];
            $backNum=$postData['backNum']??[];
            $param=[
                'inventoryTime'=>$postData['inventoryTime'],
                'status'=>$postData['status'],
                'warehouse_id'=>$warehouse_id,
                'id'=>$postData['id']??0,
            ];
            if (!$material_id||!$warehouse_id){
                return to_assign(1,'参数缺失');
            }
            Db::startTrans();
            $param['update_time']=time();
            $id=$param['id']??0;
            try {
                if ($param['id'] > 0) {
                    Db::name($this->table)->strict(false)->field(true)->update($param);
                    add_log('edit', $param['id'], $postData,$this->title);
                } else {
                    $param['inOrderNum']=orderNum('PDH');
                    $param['create_time'] = time();
                    $id = Db::name($this->table)->strict(false)->field(true)->insertGetId($param);
                    add_log('add', $id, $postData,$this->title);
                }
                foreach ($material_id as $k=>$v){
                    if (empty($material_id[$k])){
                        throw new Exception('参数有误');
                    }
                    $mxData=[
                        'material_dossier_id'=>$material_id[$k],
                        'num'=>empty($num[$k])?0:$num[$k],
                        'backNum'=>$backNum[$k]??0,
                        'dKey'=>suiji('pd'),
//                        'incom_receipt_detail_id'=>$incom_receipt_detail_id[$k],
                        'pdNum'=>'0',
                        'inventory_id'=>$id,
                        'create_time'=>time(),
                        'update_time'=>time()
                    ];

                    if (isset($mxid[$k])&&$mxid[$k]){
                        unset($mxData['create_time']);
                        unset($mxData['dKey']);
                        $mxData['id']=$mxid[$k];
                    }
                    Db::name('inventory_order_detail')->save($mxData);
                }
                add_log('add', $id, $this->param,$this->title);
                Db::commit();
            }catch (\Exception $e){
                Db::rollback();
                return to_assign(1,'操作失败:'.$e->getMessage());
            }

            return to_assign();
        } else {
            $panying=0;
            $pankui=0;
            $id = isset($param['id']) ? $param['id'] : 0;
            if ($id > 0) {
                $detail = Db::name($this->table)->where('id', $id)->field("*,(select name from fy_admin a where a.id=inventory_user)username")->find();
                View::assign('detail', $detail);
                $mxList=Db::name('inventory_order_detail')
                    ->alias('iod')
                    ->join('material_kucun_view omi',"omi.mdId=iod.material_dossier_id and omi.wId= {$detail['warehouse_id']}",'left')
                    ->where('iod.status','>','-1')
                    ->where('iod.inventory_id',$id)
                    ->field('iod.*,omi.mdBrand,omi.countNum as baseNum,omi.sendNum,omi.mdName,omi.locatorName,omi.unit,omi.specs,omi.bar_code,omi.specs')
                    ->select()->each(function ($item,$index) use (&$pankui,&$panying){
                        $item['haveNum']=$item['baseNum']-$item['sendNum'];
                        if ($item['backNum']>$item['num']&&$item['is_pd']==2){
                            $pankui+=1;
                        }
                        if ($item['backNum']<$item['num']&&$item['is_pd']==2){
                            $panying+=1;
                        }
                        return $item;
                    });
                View::assign('mxList', $mxList);
            }
            $warehouseList=Db::name('warehouse')->where('status',1)->field('id,name')->select();
            View::assign('warehouseList',$warehouseList);
            View::assign('id', $id);
            View::assign('panying', $panying);
            View::assign('pankui', $pankui);
            View::assign('defalutTime', date('Y-m-d'));

            return view('form');
        }
    }

    public function detail()
    {
        $id=$this->param['id'];
        $detail = Db::name($this->table)->where('id', $id)->field("*,
        (select username from fy_admin a where a.id=inventory_user)username,
        (select name from fy_warehouse w where w.id=warehouse_id)warehouseName")->find();
        View::assign('detail', $detail);
        $mxList=Db::name('inventory_order_detail')
            ->alias('iod')
            ->join('material_kucun_view omi',"omi.mdId=iod.material_dossier_id and omi.wId= {$detail['warehouse_id']}",'left')
            ->where('iod.status','>','-1')
            ->where('iod.inventory_id',$id)
            ->field('iod.*,omi.countNum as baseNum,omi.sendNum,omi.mdName,omi.warehouseName,omi.unit,omi.specs,omi.bar_code,omi.specs')
            ->select()->each(function ($item,$index){
                $item['haveNum']=$item['baseNum']-$item['sendNum'];
                return $item;
            });
        View::assign('mxList', $mxList);
        View::assign('id', $id);
        return view('detail');
    }
    public function addMx()
    {
        $warehouse_id=$this->param['warehouse_id']??'';
        if (request()->isPost()) {
            if (!$warehouse_id){
                return table_assign(1, '请选择仓库',['data'=>[]]);
            }
            $where[]=['mdId','>',0];
            $where[]=['wId','=',$warehouse_id];
            foreach (['bar_code','mdName','specs','mdBrand'] as $v){
                if (isset($this->param[$v])&&$this->param[$v]){
                    $where[]=[$v,'like','%'.$this->param[$v].'%'];
                }
            }
            $limit=$this->param['limit']??10;
            $list=Db::name('material_kucun_view')->where($where)
                ->paginate($limit)->each(function ($item,$index){
                    $item['haveNum']=$item['countNum']-$item['sendNum'];
                    return $item;
                });
            return table_assign(0, '', $list);
        } else {
            return \view('mx');
        }

    }
    public function removeMx()
    {
        $id=$this->param['id'];
        try {
            Db::name('inventory_order_detail')->where('id',$id)->update(['status'=>-1,'update_time'=>time(),'deleted'=>time()]);
            add_log('delete', $id, $this->param,$this->title);
        }catch (\Exception $e){
            return to_assign(1,'删除失败:'.$e->getMessage());
        }
        return to_assign();
    }
    public function onSure()
    {

        $res=InventoryOrderSever::onSure($this->param,$this->uid);
        return to_assign($res['code'],$res['msg']);
//        $id=$this->param['id']??0;
//        if (!$id){
//            return to_assign(1,'参数缺失');
//        }
//        $mx=Db::name('inventory_order_detail')->where('status',1)->where('inventory_id',$id)->select();
//        if (!$mx){
//            return to_assign(1,'请添加明细');
//        }
//        Db::startTrans();
//        try {
//            Db::name($this->table)->where('id',$id)->update(['inventory_user'=>$this->uid,'status'=>2,'update_time'=>time(),'checkTime'=>time()]);
//            Db::name('inventory_order_detail')->where('inventory_id',$id)->where('status',1)->update(['status'=>2,'update_time'=>time()]);
//            add_log('check', $id, $this->param,$this->title);
//            Db::commit();
//        }catch (\Exception $e){
//            Db::rollback();
//            return to_assign(1,'操作失败:'.$e->getMessage());
//        }
//        return to_assign(0,'操作成功');
    }

    /**
     * date:2024/4/23
     * 导入明细
     */
//    public function importMx()
//    {
//
//        try {
//            if (!isset($_FILES['file'])){
//                throw new Exception('请选择上传文件');
//            }
//            $id=$this->param['id']??'0';
//            $wid=$this->param['wid']??'0';
//            //限制上传表格类型
//            $fileExtendName = substr(strrchr($_FILES['file']["name"], '.'), 1);
//            //application/vnd.ms-excel  为xls文件类型
//            if ($fileExtendName != 'xlsx') {
//                throw new Exception('必须为excel表格，且必须为xlsx格式！');
//            }
//
//            if (!$id||!$wid){
//                throw new Exception('参数缺失');
//            }
//            if (is_uploaded_file($_FILES['file']['tmp_name'])) {
//                // 有Xls和Xlsx格式两种
////            $objReader = \IOFactory::createReader('Xlsx');
//                $objReader = IOFactory::createReader('Xlsx');
//
//                $filename = $_FILES['file']['tmp_name'];
//
//                $objPHPExcel = $objReader->setReadDataOnly(true)->load($filename);  //$filename可以是上传的表格，或者是指定的表格
//
//                $sheet = $objPHPExcel->getSheet(0);   //excel中的第一张sheet
//                $highestRow = $sheet->getHighestRow();       // 取得总行数
//                $importData = [];
//                //循环读取excel表格，整合成数组。如果是不指定key的二维，就用$data[i][j]表示。
//                for ($j = 2; $j <= $highestRow; $j++) {
//                    $dKey=$objPHPExcel->getActiveSheet()->getCell("B" . $j)->getFormattedValue();
//                    $num=(int)$objPHPExcel->getActiveSheet()->getCell("I" . $j)->getFormattedValue();
//                    $info=Db::name('inventory_order_detail')
//                        ->where('inventory_id',$id)
//                        ->where('status','>',-1)
//                        ->where('dkey',$dKey)->find();
//                   if (!$info){
//                       $warText="第".($j-1) ."行填写有误";
//                       throw new Exception($warText);
//                   }
//                     $upData=[
//                        "id" =>$info['id'],
//                        "num" =>$num,
//                        'update_time'=>time()
//                    ] ;
//                    Db::name('inventory_order_detail')->save($upData);
//                    $importData[]=$upData;
//                }
//                if ($importData){
//                    add_log('import', '', $importData,$this->title.'->导入明细');
//                }
//
//            }
//        }catch (Exception $e){
//            return to_assign(1,'操作失败:'.$e->getMessage());
//        }
//        return to_assign();
//    }
    public function importData()
    {

        Db::startTrans();
        try {
            if (!isset($_FILES['file'])){
                throw new Exception('请选择上传文件');
            }
            //限制上传表格类型
            $fileExtendName = substr(strrchr($_FILES['file']["name"], '.'), 1);
            //application/vnd.ms-excel  为xls文件类型
            if ($fileExtendName != 'xlsx') {
                throw new Exception('必须为excel表格，且必须为xlsx格式！');
            }

            if (is_uploaded_file($_FILES['file']['tmp_name'])) {
                // 有Xls和Xlsx格式两种
//            $objReader = \IOFactory::createReader('Xlsx');
                $objReader = IOFactory::createReader('Xlsx');

                $filename = $_FILES['file']['tmp_name'];

                $objPHPExcel = $objReader->setReadDataOnly(true)->load($filename);  //$filename可以是上传的表格，或者是指定的表格

                $sheet = $objPHPExcel->getSheet(0);   //excel中的第一张sheet
                $highestRow = $sheet->getHighestRow();       // 取得总行数
                $importData = [];
                //循环读取excel表格，整合成数组。如果是不指定key的二维，就用$data[i][j]表示。
                $wIds=[];
                $tims=[];
                $mdIds=[];
                $nums=[];
                for ($j = 2; $j <= $highestRow; $j++) {
                    $wid=$objPHPExcel->getActiveSheet()->getCell("A" . $j)->getFormattedValue();
                    $wid=Db::name('warehouse')->where('status',1)->where('id',$wid)->value('id');
                    if (!$wid){
                        throw new Exception('仓库不存在,行:'.($j-1));
                    }
                    $time=$objPHPExcel->getActiveSheet()->getCell("B" . $j)->getFormattedValue();
                    $time=str_replace('/','-',$time);
                    if (!$time){
                        throw new Exception('时间有误,行:'.($j-1));
                    }
                    $barCode=$objPHPExcel->getActiveSheet()->getCell("C" . $j)->getFormattedValue();
                    $mdId=Db::name('material_kucun_view')->where('bar_code',$barCode)->where('wId',$wid)->value('mdId');
                    if (!$mdId){
                        throw new Exception($barCode.'：该物料未入库,行:'.($j-1));
                    }
                    $num=(int)$objPHPExcel->getActiveSheet()->getCell("D" . $j)->getFormattedValue();
                    if (empty($num)){
                        throw new Exception('数量填写有误,行:'.($j-1));
                    }
                    $wIds[]=$wid;
                    $times[]=$time;
                    $mdIds[]=$mdId;
                    $nums[]=$num;
                }
                $res=$this->createImData($wIds,$times,$mdIds,$nums);
                if ($res['code']!=200){
                    throw new Exception($res['msg']);
                }
                $data=$res['data'];
                $inData=$data['inData'];
                $detail=$data['detail'];;
                $inventory_id=Db::name($this->table)->insertGetId($inData);
                foreach ($detail as &$v){
                    $v['inventory_id']=$inventory_id;
                }
                Db::name('inventory_order_detail')->insertAll($detail);
                add_log('import', '', $data,$this->title.'->导入明细');

                Db::commit();
            }
        }catch (Exception $e){
            Db::rollback();
            return to_assign(1,'操作失败:'.$e->getMessage());
        }
        return to_assign();
    }
    /**
     * @return \json
     * @throws \think\db\exception\DbException
     * date:2024/3/21
     * 删除
     */
    public function delete()
    {
        if (request()->isDelete()) {
            $id = get_params("id");
            $status=Db::name($this->table)->where('id','in',$id)->column('status');
            if (in_array('2',$status)){
                return  to_assign(1, "有已确认数据，不能删除");
            }
            try {
                Db::name($this->table)->where('id','in',$id)->update(['status'=>-1,'deleted'=>time()]);
                Db::name('inventory_order_detail')->where('inventory_id','in',$id)->update(['status'=>-1,'deleted'=>time()]);
                add_log('delete', $id, request()->param(),$this->title);
            }catch (\Exception $e){
                return to_assign(1, "删除失败".$e->getMessage());
            }
            return to_assign(0, "删除成功");
        } else {
            return to_assign(1, "错误的请求");
        }
    }

    public function panying()
    {

        $res=InventoryOrderSever::panying($this->param,$this->uid);
        return to_assign($res['code'],$res['msg']);
//        $id=$this->param['id']??'';
//        if (!$id){
//            return to_assign(1,'参数缺失');
//        }
//       $info=Db::name($this->table)->where('id',$id)->find();
//        if (!$info){
//            return to_assign(1,'操作有误');
//        }
//        $paList=[];
//        $mxList=Db::name('inventory_order_detail')
//            ->alias('iod')
//            ->join('material_kucun_view omi',"omi.mdId=iod.material_dossier_id and omi.wId= {$info['warehouse_id']}",'left')
//            ->where('iod.status','>','-1')
//            ->where('iod.is_pd','2')
//            ->where('iod.inventory_id',$id)
//            ->field('iod.*,omi.countNum as baseNum,omi.sendNum,omi.locator')
//            ->select();
//
//        foreach ($mxList as $item){
//            $item['haveNum']=$item['baseNum']-$item['sendNum'];
//            if ($item['haveNum']<$item['num']){
//                $item['num']=$item['num']-$item['haveNum'];
//                $paList[]=$item;
//            }
//        }
//        if (empty($paList)){
//            return to_assign(1,'没有可盘点的数据');
//        }
//        Db::startTrans();
//        try {
//            $rukuData=[
//            'type'=>'盘盈入库',
//            'orderNum'=>orderNum('RKH'),
//            'inventory_order_id'=>$id,
//            'create_user'=>$this->uid,
//            'incom_user'=>$this->uid,
//            'incomTime'=>date('Y-m-d'),
//            'checkTime'=>time(),
//            'status'=>'2',
//            'create_time'=>time(),
//            'update_time'=>time(),
//        ];
//
//            $rukuId=Db::name('in_receipt')->insertGetId($rukuData);
//             foreach ($paList as $v){
//                 if (empty($v)){
//                     throw new Exception('没有可盘点的数据');
//                 }
//                    $rukuMx=[
//                        'in_receipt_id'=>$rukuId,
//                        'warehouse_id'=>$info['warehouse_id'],
//                        'inventory_order_detail_id'=>$v['id'],
//                        'locator'=>$v['locator'],
//                        'num'=>$v['num'],
//                        'status'=>'2',
//                        'material_dossier_id'=>$v['material_dossier_id'],
//                        'create_time'=>time(),
//                        'update_time'=>time(),
//                    ];
//                    Db::name('in_receipt_detail')->insertGetId($rukuMx);
//                    Db::name('inventory_order_detail')->where('id',$v['id'])
//                        ->update(['type'=>1,'is_pd'=>1,'pdNum'=>$v['num'],'backNum'=>$item['haveNum'],'pdTime'=>time()]);
//
//                }
//            add_log('pd', $id, $paList,$this->title);
//             Db::commit();
//        }catch (\Exception $e){
//            Db::rollback();
//            return to_assign(1,'操作失败:'.$e->getMessage());
//        }
//
//        return to_assign(0,'操作成功');
}

    public function pankui()
    {

        $res=InventoryOrderSever::pankui($this->param,$this->uid);
        return to_assign($res['code'],$res['msg']);

//        $id=$this->param['id']??'';
//        if (!$id){
//            return to_assign(1,'参数缺失');
//        }
//        $info=Db::name($this->table)->where('id',$id)->find();
//        if (!$info){
//            return to_assign(1,'操作有误');
//        }
//        $paList=[];
//        $mxList=Db::name('inventory_order_detail')
//            ->alias('iod')
//            ->join('material_kucun_view omi',"omi.mdId=iod.material_dossier_id and omi.wId= {$info['warehouse_id']}",'left')
//            ->where('iod.status','>','-1')
//            ->where('iod.is_pd','2')
//            ->where('iod.inventory_id',$id)
//            ->field('iod.*,omi.countNum as baseNum,omi.sendNum,omi.locator,omi.id as incomId')
//            ->select();
//        foreach ($mxList as $item){
//            $item['haveNum']=$item['baseNum']-$item['sendNum'];
//            if ($item['haveNum']>$item['num']){
//                $item['num']=$item['haveNum']-$item['num'];
//                $paList[]=$item;
//            }
//        }
//        if (empty($paList)){
//            return to_assign(1,'没有可盘点的数据');
//        }
//        Db::startTrans();
//        try {
//            $chukuData=[
//                'type'=>'盘亏出库',
//                'inventory_order_id'=>$id,
//                'orderNum'=>orderNum('CKH'),
//                'out_user'=>$this->uid,
//                'create_user'=>$this->uid,
//                'outTime'=>date('Y-m-d'),
//                'checkTime'=>time(),
//                'status'=>'2',
//                'create_time'=>time(),
//                'update_time'=>time(),
//            ];
//
//            $chukuId=Db::name('out_receipt')->insertGetId($chukuData);
//            foreach ($paList as $v){
//                if (empty($v)){
//                    throw new Exception('没有可盘点的数据');
//                }
//                $chukuMx=[
//                    'out_receipt_id'=>$chukuId,
////                    'incom_receipt_detail_id'=>$v['incomId'],
//                    'inventory_order_detail_id'=>$v['id'],
//                    'num'=>$v['num'],
//                    "warehouse_id"=>$info['warehouse_id'],
////                    "locator"=>$info['warehouse_id'],
//                    'status'=>'2',
//                    'material_dossier_id'=>$v['material_dossier_id'],
//                    'create_time'=>time(),
//                    'update_time'=>time(),
//                ];
//                Db::name('out_receipt_detail')->insertGetId($chukuMx);
//                Db::name('inventory_order_detail')->where('id',$v['id'])
//                    ->update(['type'=>2,'is_pd'=>1,'backNum'=>$item['haveNum'],'pdNum'=>$v['num'],'pdTime'=>time()]);
//
//            }
//            add_log('pd', $id, $paList,$this->title);
//            Db::commit();
//        }catch (\Exception $e){
//            Db::rollback();
//            return to_assign(1,'操作失败:'.$e->getMessage());
//        }
//
//        return to_assign(0,'操作成功');
    }

    public function onCancel()
    {
        $res=InventoryOrderSever::onCancel($this->param,$this->uid);
        return to_assign($res['code'],$res['msg']);
    }

    public function createImData($wIds,$times,$mdIds,$nums)
    {
        $wIds1=array_unique($wIds);
        $times1=array_unique($times);
        if (count($wIds1)!=1){
            return ['code'=>400,'仓库Id填写有误'];
        }
        $wid=$wIds1[0];
        if (count($times1)!=1){
            return ['code'=>400,'调拨时间填写有误'];
        }
        $time=$times1[0];
        $mData=[];
        foreach ($mdIds as $key=>$v){
            $mkey='id_'.$v;
            if (isset($mData[$mkey])){
                $mData[$mkey]+=$nums[$key];
            }else{
                $mData[$mkey]=$nums[$key];
            }
        }
        $inData=[
            'inOrderNum'=>orderNum('PDH'),
            'warehouse_id'=>$wid,
            'inventoryTime'=>$time,
            'status'=>1,
            'deleted'=>0,
            'create_time'=>time(),
            'update_time'=>time()
        ];
        $detail=[];
        foreach ($mData as $m=>$md){
            $idkey=explode('_',$m);
            $mid=$idkey[1];
            $mdInfo=Db::name('material_kucun_view')->where('mdId',$mid)
                ->where('wId',$wid)->field('countNum,sendNum')->find();
            $haveNum=$mdInfo['countNum']-$mdInfo['sendNum'];
            $detail[]=[
                'dKey'=>suiji('pd'),
                'backNum'=>$haveNum,
                'num'=>$md,
                'pdNum'=>0,
                'material_dossier_id'=>$mid,
//                'incom_receipt_detail_id'=>1,
                'status'=>1,
                'deleted'=>0,
                'create_time'=>time(),
                'update_time'=>time()
            ];
        }
        return ['code'=>200,'msg'=>'ok','data'=>['inData'=>$inData,'detail'=>$detail]];
    }

    public function exportData()
    {
        $where=session($this->sessionKey);
        $list = Db::name($this->table)->alias('io')
            ->join('admin u','u.id=io.inventory_user','left')
            ->join('warehouse w','w.id = io.warehouse_id')
            ->where($where)
            ->order('io.id desc')
            ->field("io.*,w.name as wName,u.name as username,
                (select sum(pdNum) from fy_inventory_order_detail iod where iod.status=2 and iod.inventory_id=io.id and iod.type=1)profitNum,
                (select sum(pdNum) from fy_inventory_order_detail iod where iod.status=2 and iod.inventory_id=io.id and iod.type=2)lossNum")
            ->select()->each(function ($item){
                $item['status']=$item['status']==1?'草稿':'已确认';
                return $item;
            });
        $title = [
            'id' => 'ID',
            'wName' => '盘点仓库',
            'profitNum' => '盘盈数量',
            'lossNum' => '盘亏数量',
            'username' => '盘点人',
            'inventoryTime' => '盘点时间',
            'status' => '状态',
        ];
        $name =$this->title;
        exportXlsData($name,$title,$list);
        exit();
    }
}